var id = "";

$(function (){
	id = $("#id").val();
	btnClick();
});

function btnClick(){
	$("#jobsSave").click(function (){
		var all = $("#jobs-table tbody").find("input[type='checkbox']");
		if(all.length > 0){
			var jobIds = new Array("");
			$("#jobs-table tbody :checked").each(function (i,v){
				jobIds.push($(v).val());
			});
			RM.ajax("/system/role/bindJobs.do",{"id":id,"jobIds":jobIds},function (data){
				RM.alert(data.message);
			});
		}
	});
	
	$("#userSave").click(function (){
		var all = $("#user-table tbody").find("input[type='checkbox']");
		if(all.length > 0){
			var allUserIds = new Array();
			all.each(function (i,v){
				allUserIds.push($(v).val());
			});
			var ckUserIds = new Array("");
			$("#user-table tbody :checked").each(function (i,v){
				ckUserIds.push($(v).val());
			});
			RM.ajax("/system/role/bindUsers.do",{"id":id,"allUserIds":allUserIds,"ckUserIds":ckUserIds},function (data){
				RM.alert(data.message);
			});
		}
	});
}